import router, {resetRouter} from "@/router"
import {axios} from '@/server/axios'
const state = {
    token: '',
    userInfo: {
        login_name: '',
        filepath: ''
    },
    menuFull: {},
    menuRole: {},
    login: false,
}
const mutations = {
    SET_MENU_FULL: (state, obj) => {
        state.menuFull = obj
    },
    SET_MENU_ROLE: (state, obj) => {
        state.menuRole = obj
    },
    SET_TOKEN: (state, token) => {
        state.token = token
    },
    SET_USER_INFO: (state, userInfo) => {
        state.userInfo = userInfo
    },
    SET_LOGIN: (state, bool) => {
        state.login = bool
    },
}
const actions = {
    //账号密码登录
    accountLogin({commit}, userInfo) {
        return new Promise((resolve, reject) => {
			axios.get('/power/getRChildMenus')
            // axios.get('/power/getAllChildMenus')
                .then(res => {
                    commit('SET_LOGIN', true)
                    commit('SET_MENU_FULL', res.full)
                    commit('SET_MENU_ROLE', res.role)
                    resolve(res.role)
                })
                .catch(err => {
                    commit('SET_LOGIN', false)
                })

        })
    },
    //退出登录
    logout({commit}, state) {

    }
}
export default {
    namespaced: true,
    state,
    mutations,
    actions
}
